﻿Imports Microsoft.Reporting.WebForms

Partial Class Form_frmRptMaster
    Inherits System.Web.UI.Page

    Dim strSql As String = ""

    Enum enmTypeReport
        rptSystemConfig = 1 '-
        rptUserRight = 2 '-
        rptMenuRight = 3 '-
        rptDepartment = 4 '-
        rptBrach = 5 '-
        rptUser = 6 '-
        rptUnLock = 7
        rptHistoryLogin = 8 '-
        rptZone = 9

        rptMTSCTYPE1 = 101
        rptMOBJTYPE = 102
        rptTYPE_ID = 103
        rptMPSNRELATION = 104
        rptMOFFICETYPE = 105
        rptMOFFICEOCC = 106
        rptMASSETTYPE = 107
        rptMRELATION = 108
        rptMTSCTYPE2 = 109
        rptMTSCTYPE3 = 110


        rptMCUSTSUBTYPE = 201
        rptMMARITALSTATUS = 202
        rptMPOSITION = 203
        rptMBIZRELATION = 204

        rptMBUSINESS = 205
        rptMCHECKEVIDENCE = 206
        rptMNATIONALITY = 207
        rptMOCCUPATION = 208
        rptMPREFIX = 209




    End Enum


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not (IsPostBack) Then
            hdfRptType.Value = Request.Item("rptType")

            Dim strRptType As String = IIf(hdfRptType.Value = "", 0, hdfRptType.Value)

            If (enmTypeReport.rptSystemConfig = strRptType) Then
                SystemConfig()
            ElseIf (enmTypeReport.rptUserRight = strRptType) Then
                Dim strUserRight As String = ""
                Dim strUserRightDesc As String = ""
                strUserRight = Request.Item("UserRight")
                strUserRightDesc = Request.Item("UserRightDesc")
                UserRight(strUserRight, strUserRightDesc)
            ElseIf (enmTypeReport.rptMenuRight = strRptType) Then



                '   MenuRight()
            ElseIf (enmTypeReport.rptDepartment = strRptType) Then
                Department()
            ElseIf (enmTypeReport.rptBrach = strRptType) Then
                Branch()
            ElseIf (enmTypeReport.rptUser = strRptType) Then
                sUser()
            ElseIf (enmTypeReport.rptUnLock = strRptType) Then

            ElseIf (enmTypeReport.rptZone = strRptType) Then
                Zone()
            ElseIf (enmTypeReport.rptHistoryLogin = strRptType) Then
                HistoryLogin()
            ElseIf (enmTypeReport.rptMTSCTYPE1 = strRptType) Then
                MTSCTYPE1()
            ElseIf (enmTypeReport.rptMOBJTYPE = strRptType) Then
                MOBJTYPE()
            ElseIf (enmTypeReport.rptTYPE_ID = strRptType) Then
                TYPE_ID()
            ElseIf (enmTypeReport.rptMPSNRELATION = strRptType) Then
                MPSNRELATION()
            ElseIf (enmTypeReport.rptMOFFICETYPE = strRptType) Then
                MOFFICETYPE()
            ElseIf (enmTypeReport.rptMOFFICEOCC = strRptType) Then
                MOFFICEOCC()
            ElseIf (enmTypeReport.rptMASSETTYPE = strRptType) Then
                MASSETTYPE()
            ElseIf (enmTypeReport.rptMRELATION = strRptType) Then
                MRELATION()
            ElseIf (enmTypeReport.rptMTSCTYPE2 = strRptType) Then
                MTSCTYPE2()
            ElseIf (enmTypeReport.rptMTSCTYPE3 = strRptType) Then
                MTSCTYPE3()
            ElseIf (enmTypeReport.rptMCUSTSUBTYPE = strRptType) Then
                MCUSTSUBTYPE()
            ElseIf (enmTypeReport.rptMMARITALSTATUS = strRptType) Then
                MMARITALSTATUS()
            ElseIf (enmTypeReport.rptMPOSITION = strRptType) Then
                MPOSITION()
            ElseIf (enmTypeReport.rptMBIZRELATION = strRptType) Then
                MBIZRELATION()
            ElseIf (enmTypeReport.rptMBUSINESS = strRptType) Then
                MBUSINESS()
            ElseIf (enmTypeReport.rptMCHECKEVIDENCE = strRptType) Then
                MCHECKEVIDENCE()
            ElseIf (enmTypeReport.rptMNATIONALITY = strRptType) Then
                MNATIONALITY()
            ElseIf (enmTypeReport.rptMOCCUPATION = strRptType) Then
                MOCCUPATION()
            ElseIf (enmTypeReport.rptMPREFIX = strRptType) Then
                MPREFIX()
            End If
         
        End If
      

        With sqldtsMaster
            .SelectCommand = strSql
        End With

    End Sub

#Region "Master Amlo"

    Sub MTSCTYPE1()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMTSCTYPE1.rdlc" 'เป็น path ที่เราสร้าง report ไว้
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMTSCTYPE1" 'ต้องเป็นชื่อ datasorce ที่เราสร้างใน report
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MTSCTYPE1.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMTSCTYPE1") & " "
    End Sub

    Sub MOBJTYPE()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMOBJTYPE.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMOBJTYPE"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MOBJTYPE.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMOBJTYPE") & " "
    End Sub

    Sub TYPE_ID()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptTYPE_ID.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsTYPE_ID"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     TYPE_ID.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableTYPE_ID") & " "
    End Sub

    Sub MPSNRELATION()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMPSNRELATION.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMPSNRELATION"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MPSNRELATION.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMPSNRELATION") & " "
    End Sub

    Sub MOFFICETYPE()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMOFFICETYPE.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMOFFICETYPE"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MOFFICETYPE.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMOFFICETYPE") & " "
    End Sub

    Sub MOFFICEOCC()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMOFFICEOCC.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMOFFICEOCC"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MOFFICEOCC.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMOFFICEOCC") & " "
    End Sub

    Sub MASSETTYPE()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMASSETTYPE.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMASSETTYPE"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MASSETTYPE.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMASSETTYPE") & " "
    End Sub

    Sub MRELATION()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMRELATION.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMRELATION"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MRELATION.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMRELATION") & " "
    End Sub

    Sub MTSCTYPE2()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\MTSCTYPE2.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMTSCTYPE2"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MTSCTYPE2.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMTSCTYPE2") & " "
    End Sub

    Sub MTSCTYPE3()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMTSCTYPE3.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMTSCTYPE3"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MTSCTYPE3.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMTSCTYPE3") & " "
    End Sub

#End Region

#Region "Master KYC"

    Sub MCUSTSUBTYPE()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMCUSTSUBTYPE.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMCUSTSUBTYPE"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MCUSTSUBTYPE.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMCUSTSUBTYPE") & " " _
                & " order by CUSTSUBTYPE"
    End Sub

    Sub MMARITALSTATUS()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMMARITALSTATUS.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMMARITALSTATUS"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MTSCTYPE1.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMTSCTYPE1") & " " _
                & " order by MARITALCODE"
    End Sub

    Sub MPOSITION()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMPOSITION.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMPOSITION"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MPOSITION.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMPOSITION") & " " _
                & " order by POCODE"
    End Sub

    Sub MBIZRELATION()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptBIZRELATION.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMBIZRELATION"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MBIZRELATION.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMBIZRELATION") & " " _
                & " order by BIZRECODE"
    End Sub

    Sub MBUSINESS()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMBUSINESS.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMBUSINESS"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MBUSINESS.*" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMBUSINESS") & " " _
                & " order by BIZCODE"
    End Sub

    Sub MCHECKEVIDENCE()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMCHECKEVIDENCE.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMCHECKEVIDENCE"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MCHECKEVIDENCE.* " _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMCHECKEVIDENCE") & " " _
                & " order by CHECKCODE,type"
    End Sub

    Sub MNATIONALITY()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMNATIONALITY.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMNATIONALITY"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MNATIONALITY.* " _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMNATIONALITY") & " " _
                & " order by NATIONCODE"
    End Sub

    Sub MOCCUPATION()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMOCCUPATION.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMOCCUPATION"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MOCCUPATION.* " _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMOCCUPATION") & " " _
                & " order by OCCCODE,OCCTYPE"
    End Sub

    Sub MPREFIX()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportMaster\rptMPREFIX.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMPREFIX"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     MPREFIX.* " _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableMPREFIX") & " " _
                & " order by PREFIXCODE,PREFIXTYPE"
    End Sub


#End Region

#Region " Admin "

    Private Sub UserRight(ByVal strUserRight As String, ByVal strUserRightDesc As String)
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptUserRight.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsUserRight"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "SELECT     ur.USERRIGHT, ur.USERRIGHTDESC, ur.ROLEGHB, ur.ROLESYS, ur.ROLEDEPT, ur.ROLEZONE, ur.ROLEBRANCH, ur.ROLEUSER, dm.DEPTCODE, " _
& "                      dm.DEPTNAME, pg.PROGRAMCODE, pg.PROGRAMNAME, mr.ISSHOW, mr.MQUERY, mr.MADD, mr.MMODIFY, mr.MDELETE, mr.MPRINT " _
& "FROM         " & System.Configuration.ConfigurationSettings.AppSettings("TableSUSERRIGHT") & " ur LEFT OUTER JOIN " _
& "                      " & System.Configuration.ConfigurationSettings.AppSettings("TableUSERRIGHTDEPT") & " urd ON ur.USERRIGHT = urd.USERRIGHT LEFT OUTER JOIN " _
& "                      " & System.Configuration.ConfigurationSettings.AppSettings("TableSDEPARTMENT") & " dm ON urd.DEPTCODE = dm.DEPTCODE LEFT OUTER JOIN " _
& "                      " & System.Configuration.ConfigurationSettings.AppSettings("TableSMENURIGHT") & " mr ON ur.USERRIGHT = mr.USERRIGHT LEFT OUTER JOIN " _
& "                      " & System.Configuration.ConfigurationSettings.AppSettings("TableSPROGRAM") & " pg ON mr.PROGRAMCODE = pg.PROGRAMCODE " _
& " where mr.ISSHOW = 1  " _
& " order by pg.PROGRAMCODE asc"
        Me.ReportViewer1.SizeToReportContent = True
    End Sub

    Private Sub MenuRight()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptMenuRight.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsMenuRight"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = " SELECT  SMENURIGHT.USERRIGHT, SUSERRIGHT.USERRIGHTDESC, " _
                           & "	SMENURIGHT.PROGRAMCODE, SPROGRAM.PROGRAMNAME, " _
                           & "	SMENURIGHT.ISSHOW,SMENURIGHT.MQUERY,SMENURIGHT.MADD,SMENURIGHT.MModify, " _
                           & "	SMENURIGHT.MDELETE,SMENURIGHT.MPRINT " _
                           & " FROM    " & System.Configuration.ConfigurationSettings.AppSettings("TableSMENURIGHT") & " INNER JOIN " & System.Configuration.ConfigurationSettings.AppSettings("TableSUSERRIGHT") & " " _
                           & "				ON SMENURIGHT.USERRIGHT = SUSERRIGHT.USERRIGHT  " _
                           & "			 INNER JOIN " & System.Configuration.ConfigurationSettings.AppSettings("TableSPROGRAM") & " " _
                           & "				ON SMENURIGHT.PROGRAMCODE = SPROGRAM.PROGRAMCODE " _
                           & " where SMENURIGHT.ISSHOW=1" _
                           & " order by   SMENURIGHT.USERRIGHT asc ,SMENURIGHT.PROGRAMCODE asc "
    End Sub

    Private Sub Department()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptDepartment.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsDepartment"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "   SELECT     DEPTCODE, DEPTNAME" _
                & "  FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableSDEPARTMENT") & " " _
                & " order by DEPTCODE "
    End Sub

    Private Sub zone()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptZone.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsZone"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        'strSql = " SELECT     dept.DEPTCODE, dept.DEPTNAME, zo.ZONECODE, zo.ZONENAME, br.BRANCHCODE, " _
        '    & " br.BRANCHNAME, br.BRANCHCODEUSE" _
        '    & " FROM         ADMIN.SDEPARTMENT dept INNER JOIN" _
        '    & "          ADMIN.SBRANCH br ON dept.DEPTCODE = br.DEPTCODE INNER JOIN " _
        '    & "          ADMIN.SZONE zo ON br.ZONECODE = zo.ZONECODE " _
        '    & " where admin.zonecode <> 'ZZZ' "


        'strSql = " SELECT      zo.ZONECODE, zo.ZONENAME " _
        '        & " FROM  ADMIN.SZONE zo      " _
        '        & " where zo.zonecode <> 'ZZZ' " _
        '        & " order by zo.zonecode "


        strSql = " select zn.ZONECODE,zn.ZONENAME,dp.DEPTCODE,dp.DEPTNAME " _
          & " from " & System.Configuration.ConfigurationSettings.AppSettings("TableSZONE") & " zn join " & System.Configuration.ConfigurationSettings.AppSettings("TableSDEPARTMENT") & " dp on  zn.DEPTCODE = dp.DEPTCODE      " _
          & " where not zn.ZONECODE = 'ZZZ' " _
          & " order by dp.DEPTCODE, zn.zonecode "


    End Sub

    Private Sub SystemConfig()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptSystemConfig.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsSystemConfig"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "  SELECT     CONFIGCODE, CONFIGDESC, CONFIGNUM, CONFIGSTR, CONFIGSELECT " _
                & " from " & System.Configuration.ConfigurationSettings.AppSettings("TableSSYSTEMCONFIG") & " " _
                & " order by configindex "
    End Sub

    Private Sub Branch()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptBranch.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsBranch"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = " SELECT SDEPARTMENT.DEPTCODE, SDEPARTMENT.DEPTNAME, " _
                & "       SBRANCH.BRANCHCODE, SBRANCH.BRANCHNAME, " _
                & "       SBRANCH.ZONECODE, SZONE.ZONENAME " _
                & " FROM " & System.Configuration.ConfigurationSettings.AppSettings("TableSBRANCH") & " INNER JOIN " _
                & "      " & System.Configuration.ConfigurationSettings.AppSettings("TableSDEPARTMENT") & " ON SBRANCH.DEPTCODE = SDEPARTMENT.DEPTCODE " _
                & " INNER Join " _
                & "      " & System.Configuration.ConfigurationSettings.AppSettings("TableSZONE") & " ON SBRANCH.ZONECODE = SZONE.ZONECODE " _
                & " order by deptcode asc,branchcode asc ,zonecode asc "
    End Sub

    Private Sub suser()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptUser.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsUser"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "Select tbl_User.USERNAME, tbl_User.EMPCODE, tbl_Branch.BRANCHNAME, tbl_User.BRANCHCODE, " _
                & "      tbl_User.DEPTCODE, tbl_Dept.DEPTNAME, tbl_User.ROLECODE, tbl_User.PWDBEGINDATE, " _
                & "      tbl_User.MUSTCHANGEPWD, UserRight.USERRIGHT, UserRight.USERRIGHTDESC, " _
                & "      tbl_User.INACTIVEDATE, tbl_User.ISINACTIVE,  tbl_User.EMPNAME, " _
                & "      tbl_User.EMPLASTNAME, tbl_role.ROLENAME, tbl_User.ZONECODE " _
                & " From  " & System.Configuration.ConfigurationSettings.AppSettings("TableSUSER") & " tbl_User " _
                & "              Join " & System.Configuration.ConfigurationSettings.AppSettings("TableSBRANCH") & " tbl_Branch  On tbl_User.BRANCHCODE = tbl_Branch.BRANCHCODE " _
                & "              Join " & System.Configuration.ConfigurationSettings.AppSettings("TableSDEPARTMENT") & " tbl_Dept On tbl_User.DEPTCODE = tbl_Dept.DEPTCODE " _
                & "              Join " & System.Configuration.ConfigurationSettings.AppSettings("TableSUSERRIGHT") & " userRight On tbl_User.USERRIGHT = userRight.USERRIGHT " _
                & "              Join " & System.Configuration.ConfigurationSettings.AppSettings("TableSROLE") & " tbl_role On tbl_User.ROLECODE = tbl_role.ROLECODE" _
                & " Where tbl_User.ISINACTIVE = 0 " _
                & " Order By tbl_User.USERNAME "

    End Sub


    Private Sub HistoryLogin()
        Me.ReportViewer1.LocalReport.ReportPath = "Form\reportAdmin\rptLoginLog.rdlc"
        Dim a As New Microsoft.Reporting.WebForms.ReportDataSource
        a.DataSourceId = "sqldtsMaster"
        a.Name = "dsLoginLog"
        Me.ReportViewer1.LocalReport.DataSources.Add(a)
        strSql = "Select LogLogin.USERNAME, LogLogin.EMPNAME, LogLogin.EMPLASTNAME, LogLogin.ROLECODE, LogLogin.DEPTCODE, " _
                 & "     LogLogin.ZONECODE, LogLogin.BRANCHCODE, LogLogin.LASTIP, LogLogin.USERRIGHT, LogLogin.LOGINDATE, " _
                 & "     LogLogin.LOGINTYPE " _
                 & " From  " & System.Configuration.ConfigurationSettings.AppSettings("TableSLOGINLOG") & " LogLogin " _
                & "  Order By LogLogin.LOGINDATE Desc "

    End Sub

#End Region





End Class
